partial class SET_INCL{E} < $SET{E}
****
SET_INCL defines some of the set functions which are not dependant on the implementation of the set. The most common routines (union, intersect etc.) are special cased so that when the argument is of type SAME there is no dispatching. Be careful about create


Ancestors
$SET{_} $RO_SET{_} $STR $CONTAINER{_}
$ELT{_} $ELT RO_SET_INCL{_} COMPARE{_}

Descendants
H_SET{_} SET{_}



Public


Features
as_array: ARRAY{E} .. Included as as_array
clear
**** Expensive! To make sure that we don't overwrite while reading, use a seperate array.
stub copy: SAME; .. Included as copy
**** Return a copy of the set
copy_from(a: $ELT{E})
**** Clear old elts and insert the elements of self
create(a: ARRAY{E}): SAME
stub create: SAME;
**** Create an empty set - used by the other set create routines
create_from(e: $ELT{E}): SAME
stub delete(e:E);
**** Delete element "e" from the set
diff(s: $RO_SET{E}): SET{E} .. Included as diff
**** See the comment for "union" and $RO_SET::diff
diff_view(s: $RO_SET{E}): $RO_SET{E} .. Included as diff_view
**** See the comment for "union_view"
equals(a:$RO_SET{E}): BOOL .. Included as equals
**** Returns 'true' if every element of self is elt_eq to an element in 'a' and vice versa. Neither may be void.
stub has(e: E): BOOL; .. Included as has
**** Return true if the class has the element "e"
stub insert(e:E);
**** Insert element "e" into the set
intersection(s:$RO_SET{E}): SET{E} .. Included as intersection
**** See the comment for "union" and $RO_SET::intersection
intersection_view(s: $RO_SET{E}): $RO_SET{E} .. Included as intersection_view
**** See the note for "union_view"
is_empty: BOOL .. Included as is_empty
**** Do not do size=0. Finding size may require iteration through all elements - quite wasteful for just "is_empty"
is_subset_of(s: $RO_SET{E}): BOOL .. Included as is_subset_of
**** Return true if "self" is a subset of "s"
size: INT .. Included as size
str: STR .. Included as str
**** Prints out a string version of the array of the components that are under $STR
sym_diff(s: $RO_SET{E}): SET{E} .. Included as sym_diff
**** See the comment for "union" and $RO_SET::sym_diff
sym_diff_view(s: $RO_SET{E}): $RO_SET{E} .. Included as sym_diff_view
**** See the comment for "union_view"
to_diff(a: $ELT{E})
to_intersection(a: $ELT{E})
to_sym_diff(a: $ELT{E})
to_union(a: $ELT{E})
union(s: $RO_SET{E}): SET{E} .. Included as union
**** Union is defined by default to create a "view" and then convert that into a SET. Subtypes may redefine this behavior to return a set of type "SAME", without going through a view
union_view(s: $RO_SET{E}): $RO_SET{E} .. Included as union_view
**** Return a read-only "view" of the union of "self" and "s" The resulting view just points to the two component sets and computes its elements on-the-fly, as needed. As a result, this form of union requires almost no additional space but may it may take slightly longer to perform operations

Iters
stub elt!: E; .. Included as elt!
**** Yield the elements of the set


Private

create_from_internal(s: $RO_SET{E}): SET{E} .. Included as create_from_internal
**** Used as an auxilliary routine by the view creation routines. When the return type can be any $RO_SET, then by default a "SET" will be constructed and used
elt_eq(e1,e2:ETP):BOOL .. Included as elt_eq
**** The "less than" relation used in the sorting routines. Compares the object "id" by default. May be redefined in descendants.
elt_hash(e:ETP):INT .. Included as elt_hash
**** A hash value associated with an element. Must have the property that if "elt_eq(e1,e2)" then "elt_hash(e1)=elt_hash(e2)". Can be defined to always return 0, but many routines will then become quadratic. Uses object "id" by default. May be redefined in descendants.
elt_lt(e1,e2:ETP):BOOL .. Included as elt_lt
**** The "less than" relation used in the sorting routines. Compares the object "id" by default. May be redefined in descendants.
elt_nil: ETP .. Included as elt_nil
**** Return the nil value. If the element is under $NIL then return e.nil. Otherwise, return void
_
get_set_of_self: SAME .. Included as get_set_of_self
is_elt_nil(e:ETP):BOOL .. Included as is_elt_nil

The Sather Home Page